package com.winit.openapi.tms.builder;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.winit.tms.spi.booking.vo.BookingOrderValueAddedServiceVo;

public class BookingOrderValueAddedServiceBuilder {
    
    public static BookingOrderValueAddedServiceVo buildBookingValueAddedService(JSONObject json) {
        BookingOrderValueAddedServiceVo orderVo = new BookingOrderValueAddedServiceVo();
        if (json.containsKey("bookingOrderValueAddedServiceVo")) {
            JSONObject jsonObject = (JSONObject) json.getJSONObject("bookingOrderValueAddedServiceVo");
            if (jsonObject.containsKey("id")) {
                orderVo.setId(jsonObject.getLong("id"));
            }
            if (jsonObject.containsKey("serviceOrderNo")) {
                orderVo.setRemark(jsonObject.getString("serviceOrderNo"));
            }
            if (jsonObject.containsKey("remark")) {
                orderVo.setRemark(jsonObject.getString("remark"));
            }
            if (jsonObject.containsKey("approvalStatus")) {
                orderVo.setApprovalStatus(jsonObject.getString("approvalStatus"));
            }
            if (jsonObject.containsKey("approvalRemark")) {
                orderVo.setApprovalRemark(jsonObject.getString("approvalRemark"));
            }
            if (jsonObject.containsKey("submitDate")) {
                orderVo.setSubmitDate(jsonObject.getDate("submitDate"));
            }
            if (jsonObject.containsKey("estimateAmount")) {
                orderVo.setEstimateAmount(jsonObject.getBigDecimal("estimateAmount"));
            }
            if (jsonObject.containsKey("actualAmount")) {
                orderVo.setEstimateAmount(jsonObject.getBigDecimal("actualAmount"));
            }
        }
        return orderVo;
    }

    public static Map<String, Object> buildBookingValueAddedService(BookingOrderValueAddedServiceVo addedService) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("serviceOrderNo", addedService.getServiceOrderNo());
        map.put("remark", addedService.getRemark());
        map.put("approvalStatus", addedService.getApprovalStatus());
        map.put("approvalRemark", addedService.getApprovalRemark());
        map.put("submitDate", addedService.getSubmitDate());
        map.put("estimateAmount", addedService.getEstimateAmount());
        map.put("actualAmount", addedService.getActualAmount());
        map.put("isCharge", addedService.getIsCharge());
        map.put("estimateShelveDate", addedService.getEstimateShelveDate());
        return map;
    }
}
